package com.xpec.c4.db.model.log.basic;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.xpec.c4.db.model.basic.BasicModel;
import com.xpec.c4.db.util.LogDBUtils;
import com.xpec.c4.game.time.TimeSys;

/**
 *
 * @author Bany
 *
 * @version 创建时间：2008-6-19 下午05:36:22
 *
 */
@MappedSuperclass
public class BasicLogModel extends BasicModel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5604059145431968320L;

	protected Long eventId;

	/**
	 * 记录时间
	 */
	protected Calendar eventTime; 
	
	/**
	 * 為增進統計計算效率,新增此欄位(因為統計常常需要以日為單位計算數量)
	 */
	protected Date eventDate;
	
	/**
	 * 游戏时间
	 */
	protected long gameTime; 

	public BasicLogModel() {
		eventTime = Calendar.getInstance();
		gameTime =TimeSys.currentTimeMills();  //TimeSys.currentTimeSec(); //TimeSys.currentTimeMills();
		eventDate = eventTime.getTime();
		eventId = LogDBUtils.getRandomLong();
	}

    @Id 
    //@GeneratedValue(strategy=GenerationType.AUTO)
    //@Column(name ="eventId", nullable = false, columnDefinition ="BIGINT(20)")
	public Long getEventId()
    {
		return eventId;
	}

	public void setEventId(Long eventId) {
		this.eventId = eventId;
	}

	public Calendar getEventTime() {
		return eventTime;
	}

	public void setEventTime(Calendar eventTime) {
		this.eventTime = eventTime;
		this.eventDate = eventTime == null? null : eventTime.getTime();
	}

	public long getGameTime() {
		return gameTime;
	}

	public void setGameTime(long gameTime) {
		this.gameTime = gameTime;
	}

	@Temporal(TemporalType.DATE)
	public Date getEventDate() {
		return eventDate;
	}

	public void setEventDate(Date eventDate) {
		this.eventDate = eventDate;
	}

	
}
